<template>
    <div class="login-div">
        <vue-particles class="login-bg" color="#39AFFD" :particleOpacity="0.7" :particlesNumber="100" shapeType="circle"
            :particleSize="4" linesColor="#8DD1FE" :linesWidth="1" :lineLinked="true" :lineOpacity="0.4"
            :linesDistance="150" :moveSpeed="3" :hoverEffect="true" hoverMode="grab" :clickEffect="true" clickMode="push">
        </vue-particles>
        <div class="box-card">
            <div class="title">
                <span>XXX后台管理</span>
            </div>
            <div class="input-div">
                <el-input placeholder="请输入账号" prefix-icon="el-icon-user-solid" v-model="form.username">
                </el-input>
                <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="form.password">
                </el-input>
            </div>
            <div class="btn-div">
                <el-button type="primary" :loading="loading" @click="login">登录</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import sparkMd5 from "spark-md5";
export default {
    name: "authorization",
    data() {
        return {
            // 登录数据
            form: {
                username: "admin",
                password: "123456"
            },
            // 是否加载
            loading: false
        }
    },
    methods: {
        // 登录
        async login() {
            this.loading = true
            var spark = new sparkMd5();
            spark.append(this.form.password);
            let res = await this.$store.dispatch("getLogin", {
                username: this.form.username,
                password: spark.end()
            })
            if (res.success) {
                this.$message.success(res.message)
                setTimeout(() => {
                    this.$router.push("/dashboard")
                }, 500);
            }
            else this.$global.resError(res)
        }
    },
}
</script>

<style scoped>
.login-div {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
}

.box-card {
    margin-top: 10%;
    width: 364px;
    height: 300px;
    /* background-color: rgb(178, 209, 233); */
    padding: 30px;
    z-index: 9999;
}

.title {
    font-size: 26px;
    color: #666;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 700;
}

.input-div .el-input {
    margin: 5px 0 5px 0;
}

.btn-div button {
    margin-top: 5px;
    width: 100%;
}

#particles-js {
    width: 100%;
    height: 100%;
    /* position: absolute; */
    position: fixed;
    background-image: url(image/bg.svg);
    background-size: 100%;
}
</style>